package com.thucydides.test.steps;

import org.jbehave.core.annotations.AfterStory;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.junit.runner.RunWith;
import net.thucydides.junit.runners.ThucydidesRunner;


import com.aol.library.AolLibrary;
import com.selenium.library.Driver;

/* Author - Payal Garg
StoryName - browse_product.story
Date created - 29-05-2013*/

@RunWith(ThucydidesRunner.class)
public class BrowseScenarioSteps {
	
	AolLibrary aol;
	public BrowseScenarioSteps() throws Exception{
	
		aol = new AolLibrary();
	}

//	@Given("I am a shopper")
//	public void ImShopper() {
//		System.out.println("welcome");	
//	}
//	
//	@When("I am viewing HomePage")
//	public void viewHomePage() throws Exception{
//		
//		System.out.println("Viewing Homepage");
//		aol.openURL("http://appliancesonline.com.au");
//		aol.maximise();
//		
//	}
//	
//	@Then("I search for <product>")
//	public void searchProduct(@Named("product") String product) {
//		try{
//			System.out.println("looking for product " + product);
//			aol.searchItem("Home_search_textbox", product, "Home_search_button");
//			} catch (Exception e) {
//				e.printStackTrace();
//			}	
//		}	
//	
//	
//	@Then("I browse through <product> pages")
//	public void browseThroughProduct(@Named("product") String product) throws Exception{
//		try {
//			System.out.println("browsing through: " + product);
//			aol.browseProduct();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		
//		
//	}
	
	
	@Given("I am on AOL homepage")
	public void AOLHomepage(){
		System.out.println("welcome to appliancesonline");	
	}
	
	@When("I search for <product>")
	public void searchFor(@Named("product") String product){
		try{
		aol.searchItem("Home_search_textbox", product, "Home_search_button");
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}
	
	
	@Then("I see <product> filter page")
	public void seeProductFilterPage(@Named("product") String product){
		System.out.println("product filter page");
	}
	
	
	@Then("I browse through <product> pages")
	public void browseThroughProductPage(@Named("product") String product) throws Exception{
		aol.browseProduct();
	}
	
	@AfterStory
	public void afterStory(){
		aol.closeDriver();
	}
	

}
